
export default {
    namespaced:true,
    state: {
        userInfo:'',  //保存用户信息
    },
    mutations: {
        recordUser(state,recordUser){
            state.userInfo=recordUser
            // console.log(recordUser)
        },
        resetUserInfo(state) {  //退出登录
            state.userInfo = ''
        },
    },
    actions: {//保存用户信息
        recordUser({commit},recordUser){
            // console.log('111')
            commit('recordUser',recordUser)
            sessionStorage.setItem('userInfo',JSON.stringify(recordUser))   //把用户信息 存入sessionStorage中
        },
        // 登出
          logout({commit}) { ///logout
            commit('resetUserInfo')
            sessionStorage.removeItem("userInfo");   //删除sessionStorage里面数据
        },
    },
  }
